package com.hualude.roadsign.service.impl;

import com.hualude.roadsign.dto.AlarmPushDto;
import com.hualude.roadsign.dto.PushHistoryDto;
import com.hualude.roadsign.repository.AlarmPushRepository;
import com.hualude.roadsign.repository.PushHistoryRepository;
import com.hualude.roadsign.service.PushHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PushHistoryServiceImpl implements PushHistoryService {

    @Resource
    private PushHistoryRepository pushHistoryRepository;
    @Resource
    private AlarmPushRepository alarmPushRepository;

    @Override
    public List<PushHistoryDto> getPushHistoryByOrgIdAndActorId(Integer orgId,
                                                                String actorIds,
                                                                Integer mCount,
                                                                Integer mSize) throws Exception {
        return pushHistoryRepository.getPushHistoryByOrgIdAndActorId(orgId, actorIds, mCount, mSize);
    }

    @Override
    public Integer addPushHistory(PushHistoryDto pushHistoryDto) throws Exception {
        return pushHistoryRepository.save(pushHistoryDto.toBean()).getPushHistoryId();
    }

    @Override
    public List<AlarmPushDto> getAlarmPushHistory(Integer alarmType, String orgIds, String actors, Integer mCount, Integer mSize) throws Exception {
        return alarmPushRepository.getAlarmPushHistory(alarmType, orgIds, actors, mCount, mSize);
    }


    public List<AlarmPushDto> getAlarmTypeCount(String limitTime, String orgIds) throws Exception {
        return alarmPushRepository.getAlarmTypeCount(limitTime, orgIds);
    }

    @Override
    public List<PushHistoryDto> getFaultHistoryByOrgIdAndType(Integer orgId, Integer pushType, Integer mCount, Integer mSize) throws Exception {
        return pushHistoryRepository.getFaultPushList(orgId,pushType,mCount,mSize);
    }


}
